package com.jiuling.qiniu.oss.spring.config;

import com.jiuling.qiniu.config.QiNiuConfig;
import com.jiuling.qiniu.oss.FileUploud;
import com.jiuling.qiniu.oss.ResourceManagement;
import com.jiuling.qiniu.oss.config.QiNiuOssConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author 紫灵
 * @date 2023年05月24日 15时04分09秒
 */
@Component
@Configuration
public class QiNiuOssBeanConfig {

    private final QiNiuConfig qiNiuConfig;

    public QiNiuOssBeanConfig(QiNiuConfig qiNiuConfig) {
        this.qiNiuConfig = qiNiuConfig;
    }

    @Bean
    @ConfigurationProperties(prefix = "jiu-ling.qiniu.oss")
    public QiNiuOssConfig qiNiuOssConfig(){
        QiNiuOssConfig qiNiuOssConfig = new QiNiuOssConfig();
        qiNiuOssConfig.setQiNiuConfig(qiNiuConfig);
        return qiNiuOssConfig;
    }

    @Bean
    public FileUploud fileUploud(){
        return new FileUploud(qiNiuOssConfig());
    }

    @Bean
    public ResourceManagement resourceManagement(){
        return new ResourceManagement(qiNiuOssConfig());
    }


}
